//
//  UIButton+Block.m
//  IBoXiao_ios
//
//  Created by 于龙 on 14-3-25.
//  Copyright (c) 2014年 ___boxiao___. All rights reserved.
//

#import "UIButton+Block.h"

@implementation UIButton (Block)

static char overviewKey;

@dynamic event;

- (void)handleControlEvent:(UIControlEvents)event withBlock:(ActionBlockk)block {
    
    objc_setAssociatedObject(self, &overviewKey, block, OBJC_ASSOCIATION_COPY_NONATOMIC);
    [self addTarget:self action:@selector(callActionBlock:) forControlEvents:event];
}


- (void)callActionBlock:(id)sender {
    ActionBlockk block = (ActionBlockk)objc_getAssociatedObject(self, &overviewKey);
    if (block) {
        block();
    }
}

@end
